package com.example.xd.tuiliu_test.videoplayer.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

import com.example.xd.tuiliu_test.R;

import java.util.Date;



public class ListItemPlayerView extends InitByOtherPlayerView {
    public ListItemPlayerView(Context context) {
        super(context);
    }

    int itemIndex;

    public ListItemPlayerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ListItemPlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void fullScreen() {

    }

    @Override
    public void exitFullScreen() {

    }

    @Override
    protected void initView() {
        super.initView();
        full_screen.setVisibility(GONE);
    }

    public int getItemIndex() {
        return itemIndex;
    }

    public void setItemIndex(int itemIndex) {
        this.itemIndex = itemIndex;
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (isAniming)
            return false;
        if (shieldingTouch)
            return false;
        if (player == null) {
            return false;
        }
        if (v.getId() == R.id.ll_controller) {
            return false;
        }
        int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                touchStartTime = new Date().getTime();
                break;
            case MotionEvent.ACTION_MOVE:
                break;
            case MotionEvent.ACTION_UP:
                if (new Date().getTime() - touchStartTime < 150) {
                    if (showController) {
                        closeController();
                    } else {
                        showController();
                    }
                }
                break;
        }
        return true;
    }

    public void onItemRollOut() {
        if (status != null) {
            status.onItemRollOut();
        }
    }
}
